// miniprogram/pages/order/order.js
const {all_kinds,left_nav} = require('../../data/kind')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    collection:true,
    currentKind: 'cat-0',
    tem:true,
    boolean:true,
    active:'',
    activeTabIndex: 0,
    activeNavIndex:0,
    kindLeft_nav:left_nav,
    cats: Object.keys(all_kinds),
    all_kinds:all_kinds
  },
  bindChange(e){
    console.log(e);
  },
  collectionEvent(e){
    // console.log(e);
    this.setData({
      collection:!this.data.collection
    })
    wx.showToast({
      title: '已取消收藏',
      icon:'none'
    })
    if(this.data.collection==false){
      wx.showToast({
        title: '收藏成功',
        icon:'none'
      })
    }
  },
  Event(e){
    this.setData({
      tem:!this.data.tem,
      boolean:!this.data.boolean
    })
  },
  changeKind(e) {
    let id = e.currentTarget.dataset.index;
    // console.log(id);
    this.setData({
      currentKind: 'cate-' + id
    })
  },
  switchFetchType(e) {
    console.log(e)
    let index = e.currentTarget.dataset.index;
    this.setData({
      activeTabIndex: index
    })
  },
  onChange(event) {
    this.setData({
      active: event.detail,
    });
  },
  search(event){
    wx.navigateTo({
      url: `../search/search?id=${event.target.dataset.id}`
    })
  },
  carry(event){
    console.log(event,'-----')
    wx.navigateTo({
      url: `../carry/carry?id=${event.target.dataset.id}`
    })
  },
  map(event){
    wx.navigateTo({
      url: `../map/map?id=${event.target.dataset.id}`
    })
  },
  switchTab(e){
    let index = e.currentTarget.dataset.index;
    if(index == this.data.activeTabIndex){
      return 0;
    }
    this.setData({
      activeTabIndex:index,
      activeSwiperIndex:index
    })
  },
  changeKinds(e) {
    console.log(e);
    let {index, type} = e.currentTarget.dataset;
    console.log(index, type);
    this.setData({
      activeNavIndex:index
    })
  },
  onPullDownReFresh(){
  //   setTimeout:(() => {
  //     this.setData({
  //     items:arr,
  //     scrollTop:0
  //     })
  //     wx.stopPullDownReFresh()
  //   }, 1000)
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})